import { NextResponse } from 'next/server';
import { API_CONFIG } from '@/app/config';

export async function POST(req: Request) {
  try {
    const body = await req.json();
    const { id } = body;
    const response = await fetch(`${API_CONFIG.BASE_URL}/api/goods/getGoodsByCategory`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ id }),
    });
    const data = await response.json();
    return NextResponse.json(data);
  } catch (error) {
    return NextResponse.json({ error: 'Failed to fetch products' }, { status: 500 });
  }
}